<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateUsersTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('users', function (Blueprint $table) {
            $table->engine = 'InnoDB';
            $table->charset = 'utf8';
            $table->collation = 'utf8_unicode_ci';

            $table->bigIncrements('id');
            $table->string('username',128)->comment('用户名');
            $table->char('password',32)->comment('密码');
            $table->string('remarks',128)->nullable()->comment('备注');
            $table->string('phone',15)->nullable()->comment('电话号码');
            $table->string('email',128)->nullable()->comment('邮箱');
            $table->smallInteger('status')->default(1)->comment('状态');
            $table->smallInteger('type')->default(1)->comment('用户类型，0-外部用户，1-内部用户，2-超级管理员');
            $table->char('user_code', 32)->comment('用户加密码');
            $table->timestamps();

            $table->index(['username', 'password']);
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('users');
    }
}
